<?php

namespace app\admin\validate;

use \think\Validate;

/**
 *  用户登录
 */


class Operator extends Validate
{

    protected $rule = [
        'id' => 'require|number',
        'ids' => 'require|array',
        'cname' => 'require',
        'phone' => 'mobile',
        'email' => 'email',
        'nickname' => 'require',
        'password' => 'length:6,18',
        'department' => 'require',
        'position' => 'require',
        'status' => 'in:0,1',
        'remark' => 'require',
        'isadmin' => 'in:0,1',
        'roles' => 'require',
        'role_ids' => 'require',

    ];

    //定义验证提示
    protected $message = [
        'id.require' => 'ID 不能为空',
        'ids.require' => 'IDS 不能为空',
        'ids.array' => 'IDS 只能是数组',
        'id.number' => 'ID 只能是数字',
        'cname.require' => '名字不能为空',
        'phone.mobile' => '手机号码错误',
        'email.email' => '邮箱格式错误',
        'nickname.require' => '昵称不能为空',
        'password.length' => '密码位数请在 (6 ~ 18 )位之间',
        'department.require' => '部门不能为空',
        'position.require' => '职位不能为空',
        'status.in' => '状态必须是 0 或 1',
        'remark.require' => '描述不能为空',
        'isadmin.in' => '是否是管理员值 0 或 1',
        'roles.require' => '权限不能为空',
        'role_ids.require' => '角色不能为空',
    ];

    //定义验证场景
    protected $scene = [
        'account' => [],
        'list' => ['cname'],
        'add' => ['cname', 'phone', 'email', 'password', 'status', 'isadmin'],
        'update' => ['id', 'cname', 'phone', 'email', 'password', 'status', 'isadmin'],
        'create' => ['cname', 'phone', 'department', 'email'],
        'detail' => ['id'],
        'remove' => ['id'],
        'del' => ['ids'],
        'assignRole' => ['id', 'role_ids'],
    ];
}
